package com.attendancesystem.controller;


import com.attendancesystem.model.Admin;
import com.attendancesystem.service.AdminInfoService;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.*;



import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.sql.*;
import java.util.List;

@WebServlet(name = "AdminInfoController", value = "/AdminInfoController")
public class AdminInfoController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");

        HttpSession session = request.getSession();
        String AdminId = (String) session.getAttribute("adminName");
        System.out.println("AdminId:"+AdminId);
        AdminInfoService adminInfoService = new AdminInfoService();
       Admin admin= adminInfoService.getAllAdminInfo(AdminId);
        request.setAttribute("Admin",admin);
        System.out.println("AdminList:"+admin);
        request.getRequestDispatcher("/WEB-INF/views/Admin.jsp").forward(request, response);



    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);

    }
}
